#ifndef AIIMAGEUTILS_H
#define AIIMAGEUTILS_H
#include "inc/im2d_type.h"
#include <opencv2/core/mat.hpp>
#include "inc/im2d_buffer.h"
#include "inc/im2d_single.h"
#include "inc/im2d_common.h"

typedef enum {
    IMAGE_FORMAT_GRAY8,
    IMAGE_FORMAT_RGB888,
    IMAGE_FORMAT_RGBA8888,
    IMAGE_FORMAT_YUV420SP_NV21,
    IMAGE_FORMAT_YUV420SP_NV12,
} image_format_t;

typedef struct {
    int width;
    int height;
    int width_stride;
    int height_stride;
    image_format_t format;
    unsigned char* virt_addr;
    int size;
    int fd;
} image_buffer_t;

typedef struct {
    int x_pad;
    int y_pad;
    float scale;
} letterbox_t;

typedef struct {
    int left;
    int top;
    int right;
    int bottom;
} image_rect_t;

cv::Mat cropToMultipleOf16(const cv::Mat& image);
int get_image_size(image_buffer_t* image);
int convert_image(image_buffer_t* src_img, image_buffer_t* dst_img, image_rect_t* src_box, image_rect_t* dst_box, char color);
//static int convert_image_rga(image_buffer_t* src_img, image_buffer_t* dst_img, image_rect_t* src_box, image_rect_t* dst_box, char color);
int convert_image_with_letterbox(image_buffer_t* src_image, image_buffer_t* dst_image, letterbox_t* letterbox, char color);

#endif // AIIMAGEUTILS_H
